package com.enqualcomm.kids.manager;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.enqualcomm.kids.R;
import com.enqualcomm.kids.config.userdefault.UserTerminalDefault;
import com.enqualcomm.kids.mvp.reai.ShadowTransformer;
import com.enqualcomm.kids.mvp.reai.TerminalListView;
import com.enqualcomm.kids.view.ReaiBookView;
import com.facebook.drawee.view.SimpleDraweeView;

import common.utils.DensityUtil;

/**
 * Created by Sunzhigang on 2016/7/1.
 */
public class OldManModeHandlerImp1 implements ModeHandler {
    @Override
    public void initMode(Context context, View rootRL
            , boolean q_a_enable, boolean find_enable, boolean family_enable, boolean wechat_enable, boolean make_call_enable
            , UserTerminalDefault mCurrentUserTerminalDefault, SimpleDraweeView header_iv, boolean oscard_enable, ShadowTransformer shadowTransformer) {

        /**下排按钮*/
//        View app_setting_btn = rootRL.findViewById(R.id.app_setting_btn);
//        View all_terminals_btn = rootRL.findViewById(R.id.all_terminals_btn);
        View dial_btn = rootRL.findViewById(R.id.dial_btn);
        TextView dial_tv = (TextView) rootRL.findViewById(R.id.dial_tv);
        View chat_btn = rootRL.findViewById(R.id.chat_btn);
        TextView chat_tv = (TextView) rootRL.findViewById(R.id.chat_tv);
        View control_btn = rootRL.findViewById(R.id.control_btn);
        TextView control_tv = (TextView) rootRL.findViewById(R.id.control_tv);
        /**头像*/
//        SimpleDraweeView header_iv= (SimpleDraweeView) rootRL.findViewById(R.id.header_iv);

        View phone_book_btn = rootRL.findViewById(R.id.phone_book_btn);
        TextView phone_book_tv = (TextView) rootRL.findViewById(R.id.phone_book_tv);
        /**计步*/
        TextView pedometer_tv = (TextView) rootRL.findViewById(R.id.pedometer_tv);
        /**书页*/
        ReaiBookView zainaer_rl = (ReaiBookView) rootRL.findViewById(R.id.zainaer_rl);
        ImageView kanshijie_rl = (ImageView) rootRL.findViewById(R.id.kanshijie_rl_bg);
//        ReaiBookView oscard_rl = (ReaiBookView) rootRL.findViewById(R.id.oscard_rl);
//        ReaiBookView aizhishi_rl = (ReaiBookView) rootRL.findViewById(R.id.aizhishi_rl);
        /**书签*/
        ImageView book_marker1 = (ImageView) rootRL.findViewById(R.id.book_marker1);
        ImageView book_marker2 = (ImageView) rootRL.findViewById(R.id.book_marker2);
        ImageView book_marker3 = (ImageView) rootRL.findViewById(R.id.book_marker3);
        ImageView book_marker4 = (ImageView) rootRL.findViewById(R.id.book_marker4);
        /**星座*/
//        ReaiBookView constellation_iv= (ReaiBookView) rootRL.findViewById(R.id.constellation_iv);
        /**头像下拉*/
//        TerminalListView terminal_list= (TerminalListView) rootRL.findViewById(R.id.terminal_list);

//        rootRL.setBackgroundResource(R.drawable.bg_reai_main_old);
        pedometer_tv.setBackgroundResource(R.drawable.bg_pedometer_n_old);
//        pedometer_tv.setPadding(0, 0, 0, 0);
//        app_setting_btn.setBackgroundResource(R.drawable.bg_reai_setting_btn_old);
        ImageView zainaer_rl_bg = (ImageView) rootRL.findViewById(R.id.zainaer_rl_bg);
        zainaer_rl_bg.setBackgroundResource(R.drawable.bg_reai_book1_non_old);
        ImageView kanshijie_rl_bg = (ImageView) rootRL.findViewById(R.id.kanshijie_rl_bg);
        kanshijie_rl_bg.setBackgroundResource(R.drawable.bg_reai_book3_old);
//        header_iv.setBackgroundResource(R.drawable.reai_header_bg_old);
//        MyLogger.jLog().i(header_iv.hashCode());//153915531,197693768,197693768
//        all_terminals_btn.setBackgroundResource(R.drawable.bg_reai_all_terminals_btn_old);

        book_marker1.setImageResource(R.drawable.selector_book_marker1_old);//书签
        book_marker4.setImageResource(R.drawable.selector_book_marker4_old);
        book_marker2.setVisibility(View.INVISIBLE);


//        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) book_marker1.getLayoutParams();
//        layoutParams.topMargin = DensityUtil.dip2px(context, 403);
//        layoutParams.leftMargin = DensityUtil.dip2px(context, 25);
//        book_marker1.setLayoutParams(layoutParams);
//        layoutParams = (RelativeLayout.LayoutParams) book_marker4.getLayoutParams();
//        layoutParams.topMargin = DensityUtil.dip2px(context, 403);
//        layoutParams.rightMargin = DensityUtil.dip2px(context, 25);
//        book_marker4.setLayoutParams(layoutParams);
        if (find_enable) {
            book_marker4.setVisibility(View.VISIBLE);
        } else {
            book_marker4.setVisibility(View.INVISIBLE);
        }

        if (oscard_enable) {
            book_marker3.setVisibility(View.VISIBLE);
        } else {
            book_marker3.setVisibility(View.INVISIBLE);
        }

        /**进行新参数设置*/
//            mConroller.getVolumeNoticeHandler().initVolumeNotice(time_btn,time_tv,"");

        /**星座*/
//        constellation_iv.setVisibility(View.GONE);
//        constellation_iv.setBackgroundColor(context.getResources().getColor(R.color.transparent));
//        constellation_iv.setClickable(false);
//        constellation_iv.setBackgroundResource(R.drawable.heart_rate_button);
//        constellation_iv.setClickable(true);
//        constellation_iv.setTag("Heart");

        dial_btn.setBackgroundResource(R.drawable.bg_reai_dial_btn_old);//底部按钮
        chat_btn.setBackgroundResource(R.drawable.bg_reai_chat_btn_old);
        phone_book_btn.setBackgroundResource(R.drawable.bg_reai_time_btn_old);
        control_btn.setBackgroundResource(R.drawable.bg_reai_control_btn_old);
//        dial_tv.setVisibility(View.GONE);
//        chat_tv.setVisibility(View.GONE);
//        phone_book_tv.setVisibility(View.GONE);
//        control_tv.setVisibility(View.GONE);
//        terminal_list.old();

        View wechat_rl = rootRL.findViewById(R.id.wechat_rl);
        View phone_book_rl = rootRL.findViewById(R.id.phone_book_rl);
        if (family_enable) {
            phone_book_rl.setVisibility(View.VISIBLE);
        } else {
            phone_book_rl.setVisibility(View.GONE);
        }

        if (wechat_enable) {
            wechat_rl.setVisibility(View.VISIBLE);
        } else {
            wechat_rl.setVisibility(View.GONE);
        }

        View dial_btn_rl = rootRL.findViewById(R.id.dial_btn_rl);
        if (make_call_enable) {
            dial_btn_rl.setVisibility(View.VISIBLE);
        } else {
            dial_btn_rl.setVisibility(View.GONE);
        }

        int width = DensityUtil.dip2px(context, 36.7f);
        Drawable leftBtnBg = ContextCompat.getDrawable(context, R.drawable.icon_add_terminal_old);
        leftBtnBg.setBounds(0, 0, width, width);
        ((Button) rootRL.findViewById(R.id.add_watch_btn)).setCompoundDrawables(null, leftBtnBg, null, null);

        Drawable rightBtnBg = ContextCompat.getDrawable(context, R.drawable.bg_reai_setting_btn_old);
        rightBtnBg.setBounds(0, 0, width, width);
        ((Button) rootRL.findViewById(R.id.app_setting_btn)).setCompoundDrawables(null, rightBtnBg, null, null);

        ((ImageView) rootRL.findViewById(R.id.tree_iv)).setImageResource(R.drawable.tree_old);
        rootRL.setBackgroundColor(ContextCompat.getColor(context, R.color.cyp_home_bg_old));

        if (shadowTransformer != null) {
            shadowTransformer.old();
        }
    }
}
